﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TP1___Gestion_Clavier
{
	public partial class Bureau : UserControl
	{
		public int X { get; set; }
        public int Y { get; set; }
		
		public Bureau()
		{
			// Requis pour initialiser des variables
			InitializeComponent();
		}
		
		public void Draw()
		{		
			// Affichage au bon endroit
			Canvas.SetLeft(this, this.X);
			Canvas.SetTop(this, this.Y);
		}
		
		public bool Deplacer(Eleve.Direction dir, MainPage mp)
		{
			int new_x = this.X;
			int new_y = this.Y;
			switch (dir)
			{
				case Eleve.Direction.haut :
					new_y -= 50;
					break;
				case Eleve.Direction.bas :
					new_y += 50;
					break;
				case Eleve.Direction.droite :
					new_x += 50;
					break;
				case Eleve.Direction.gauche :
					new_x -= 50;
					break;
				case Eleve.Direction.haut_gauche :
					new_y -= 50;
					new_x -= 50;
					break;
				case Eleve.Direction.haut_droite :
					new_y -= 50;
					new_x += 50;
					break;
				case Eleve.Direction.bas_gauche :
					new_y += 50;
					new_x -= 50;
					break;
				case Eleve.Direction.bas_droite :
					new_y += 50;
					new_x += 50;
					break;
			}
			if (mp.Zone_OK(new_x, new_y, 50, 50, dir))
			{
				this.X = new_x;
				this.Y = new_y;
				return true;
			}
			else
			{
				return false;
			}
			//this.Draw();
		}
	}
}